

//existsSync 检测目录是否存在  statSync 判断文件是否存在
const {existsSync,statSync,readdirSync,readFileSync} = require("fs");
const path = require("path")

//console.log(__dirname);  //当前文件的路径
//console.log(process.cwd());  //当前文件夹的路径
const rootPath = process.cwd()
console.log(rootPath);
//判断当前文件夹是否存在
/* if(existsSync(rootPath)){
    //isDirectory 判断是否是文件夹
    if(statSync(rootPath).isDirectory())
    {
        //文件夹下的目录
        const dirarr = readdirSync(rootPath)
        console.log(dirarr);
    }
}
 */

let pag = process.argv[2];
let dirpath = path.join(rootpath,pag)
console.log(rootpath,packs)
if(existsSync(dirpath)){
    if(statSync(dirpath).isFile()){
        console.log("是文件");
        console.log(readFileSync(dirpath).toString())
    } else {
        console.log('是文件夹')
    }
}